package apy.codecase.business.view.fragment;

import java.util.HashMap;
import java.util.Map;

import apy.codecase.base.BaseFragment;

/**
 * Created by Administrator on 2017/10/25.
 */

public class FragmentFactory {

    private static Map<Integer, BaseFragment> map = new HashMap<>();

    public static BaseFragment createFragment(int position) {
        BaseFragment fragment = map.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new PswFragment();
                    break;
                case 1:
                    fragment = new TallyFragment();
                    break;
                case 2:
                    fragment = new DiaryFragment();
                    break;
                case 3:
                    fragment = new MeFragment();
                    break;

            }
            if (fragment != null) {
                map.put(position, fragment);
            }
        }
        return fragment;
    }
}
